function showmesh(node, elem)

dim = size(node, 2);

if ~iscell(elem) && dim == 2
    h = patch('Faces', elem, 'Vertices', node);
end

if iscell(elem)
    if iscell(elem{1})
        elem = vertcat(elem{:});
    end
    max_n_vertices = max(cellfun(@length, elem));
    padding_func = @(vertex_ind) [vertex_ind, NaN(1, max_n_vertices-length(vertex_ind))];
    tpad = cellfun(padding_func, elem, 'UniformOutput', false);
    tpad = vertcat(tpad{:});
    h = patch('Faces' , tpad, 'Vertices' , nodeasc);
end

facecolor = [0.5 0.9 0.45];
set(h, 'facecolor', facecolor, 'edgecolor', 'k');
axis equal;
axis tight;

end